#!/usr/bin/env python

import sys
import re

def main():

   if len(sys.argv) == 3:

      counter = 1

      f = open(sys.argv[1])

      for line in f:

         if line.startswith('DSC'):
            m = re.search(sys.argv[2], line)
            if m:
               line = line[:m.start()] + '#' + str(counter) + line[m.start():]
               counter += 1

         print line,

      f.close()

   else:
      print("Usage: %s tdifile pattern" % sys.argv[0])

if __name__ == "__main__":
   main()